import numpy as np

length = 1000000
img_size = 64
x_shape=(length, img_size, img_size, 3)
y_shape=(length,)

tiny_file = 'D:\\PycharmProjects\\datasets\\aux_indistribution\\tiny_edm_1m.npz'
data = np.load(tiny_file)
xx = data['image']
yy = data['label']

fpc = np.memmap('D:\\PycharmProjects\\datasets\\aux_indistribution\\tiny_edm_1m_x.npy', mode='w+', dtype='uint8', shape=x_shape)
fpc[:]=xx[:]
del fpc
fpc = np.memmap('D:\\PycharmProjects\\datasets\\aux_indistribution\\tiny_edm_1m_y.npy', mode='w+', dtype='uint8', shape=y_shape)
fpc[:]=yy[:]
del fpc

memapx = np.memmap('D:\\PycharmProjects\\datasets\\aux_indistribution\\tiny_edm_1m_x.npy', mode='r', dtype='uint8', shape=x_shape)
memapy = np.memmap('D:\\PycharmProjects\\datasets\\aux_indistribution\\tiny_edm_1m_y.npy', mode='r', dtype='uint8', shape=y_shape)

for i in range(0, length):
    if (not (xx[i]==memapx[i]).all()) or yy[i]!=memapy[i]:
        print('error')
print('done')



